//
//  BluetoothManager.h
//  蓝牙
//
//  Created by 赵鹏宇 on 16/1/25.
//  Copyright © 2016年 赵鹏宇. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>

#import "GWPeripheral.h"

typedef NS_ENUM(NSUInteger, BTPeripheralType) {
    BTPeripheralTypeCrosby,
    BTPeripheralTypeGlowaler,
};

@protocol BluetoothManagerDelegate <NSObject>

@required
- (void)didUpdatePeripheralsArray:(NSArray *)array;
- (void)didConnectedPeripheral:(GWPeripheral *)model;
@optional
- (void)didDisconnectPeripheral:(GWPeripheral *)model;
- (void)didFailToConnectPeripheral:(GWPeripheral *)model;

@end

@interface BluetoothManager : NSObject

@property (nonatomic,strong,readonly) NSMutableArray *address;
@property (nonatomic,weak) id<BluetoothManagerDelegate> delegate;
@property (nonatomic,strong) NSMutableArray *peripheralsNameArray;
@property (nonatomic, strong) NSMutableArray *connectedPeripherals;
@property (nonatomic,copy) void(^lampStateBlock)(BOOL isON);//灯的开关状态
@property (nonatomic,copy) void(^ConnectedPeripheralBlock)(BOOL isConnected);//连接到蓝牙的回调

@property (nonatomic, assign) BTPeripheralType peripheralType;

+ (instancetype)standardManager;
- (void)startDiscoverPeripheral;
- (void)startConnectPeripheralWithName:(NSString *)peripheralMacAds;
- (void)cancelPeripheralConnection:(NSString *)peripheralMacAds;
- (void)writCommad:(NSString *)commad;

- (void)writeCommad:(NSString *)commad onDevice:(NSString *)peripheralMacAds;

- (void)setFalgWithAddress:(NSString *)address withFlag:(NSString *)flag;
- (NSString *)getFlagWithAddress:(NSString *)address;




@end
